#ifndef XGE_GRAPHICS_NODE_RENDER_TARGET_H_
#define XGE_GRAPHICS_NODE_RENDER_TARGET_H_
#include "xge_common_config.h"

#include "node_spritenode.h"

#include "g_rendertarget.h"

namespace xge{
namespace graphics{

  // Render target node is used to render the target on this
  // node , it will render the scene to this target and batch
  // the operation like an sprite node ,so you can easily use
  // this node as the off screen target !
  // All the child node rendering will render to the target ,
  // and you can manipulate this node as you wish !

  class RenderTargetNode : public SpriteNode {
  public:
    // RenderTargetNode ctor
    RenderTargetNode( size_t width , size_t height );
    // RenderTargetNode OnPaint function
    virtual void OnPaint( const Timer::tick_t& time_diff );
    // The dtor will destroy all the internal object here
    ~RenderTargetNode();
  private:
    // The pointer to the internal render target object 
    RenderTarget* render_target_;
    // Since we will take use of SpriteNode however , the
    // sprite node store the texture as shared_ptr , and the
    // shared_ptr will use the Graphics2D::DestroyTexture to
    // destroy this texture ,however the render target's texture
    // will not be deleted by the DestroyTexture but automatically
    // In order to meet the demand , we use a fake TexturePtr 
    // which will not calling the DestroyTexture
    int8_t fake_texture_ptr_ [sizeof(TexturePtr)];
    friend class BaseNode;
  };

}// namespace graphics
}// namespace xge

#endif// XGE_GRAPHICS_NODE_RENDER_TARGET_H_